package br.usjt.component.login.mb;

import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

import br.com.usjt.component.commons.login.exceptions.BadCredentialsException;
import br.usjt.component.login.dto.LoginDTO;
import br.usjt.component.login.facade.LoginBeanRemote;

@ManagedBean
@RequestScoped
public class LoginMBean {

    LoginDTO dto;

    @EJB
    LoginBeanRemote loginBean;

    public void efetuarlogin() {
        try {
            loginBean.efetuarLogin("thiago", "thiago");
        } catch (BadCredentialsException e) {
            System.out.println("foi?????");
        }
    }

    public void salvaUsuario() {
        LoginDTO login = new LoginDTO();
        login.setLogin("thiago");
        login.setSenha("thiago");
        login.setStatus(true);

        loginBean.salvar(login);
    }

    @PostConstruct
    public void init() {
        this.dto = new LoginDTO();
    }
}
